package com.hb.back.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hb.back.domain.EduAclPermission;
import com.hb.back.service.EduAclPermissionService;
import com.hb.back.mapper.EduAclPermissionMapper;
import com.hb.common.vo.MentVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 *
 */
@Service
public class EduAclPermissionServiceImpl extends ServiceImpl<EduAclPermissionMapper, EduAclPermission>
    implements EduAclPermissionService{

@Autowired
EduAclPermissionMapper aclPermissionMapper;

        @Override
        public List<MentVo> getChilderMenus(String name) {
          List<MentVo>list=aclPermissionMapper.selMenusByUsername(name,"1");
          list.stream().map(m->{
              List<MentVo> list1 = aclPermissionMapper.selMenusByUsername(name, m.getId());
              for (MentVo mentVo : list1) {
                   mentVo.setHidden(mentVo.getType()==3);
                   mentVo.setChildren(new ArrayList<>());
              }
              m.setChildren(list1);
              m.setRedirect(m.getPath()+"/"+m.getChildren().get(0).getPath());
              return m;
        }).collect(Collectors.toList());
          return list;
        }
}




